<template>
  <div class="content">
    <div class="welcome_content">
      <div class="welcome_text">
        <p>欢迎来到</p>
        <p>妙影照相馆</p>
      </div>
      <div class="welcome_english">
        <p>Welcome to</p>
        <p>Miao Ying photo studio</p>
      </div>
      <div class="button_content">
        <button class="button_confirm btn_white f18" @click="login" :disabled="!openId">登录</button>
        <button class="button_confirm btn_regist f18 mt25" @click="register" :disabled="!openId">注册</button>
      </div>
    </div>
  </div>
</template>

<script>
  import {getWXSign} from '@/api/wxsdk'
  import wx from 'weixin-js-sdk'
  import {MP} from '@/utils/map.js'

  export default {
    data() {
      return {
        userTel: '',
        userPw: '',
        openId: '',
        ak:'1287348913029483740293'//密钥
      }
    },
    mounted() {
      let that = this
      getWXSign()
        .then(res => {
          wx.getLocation({
            type: 'wgs84', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
            success: function (res) {

             /* var _this = this;
              MP(_this.ak).then(BMap => {
                //在此调用api

                if(res.errMsg=="getLocation:fail") {
                  alert(JSON.stringify(res));
                  var gc = new BMap.Geocoder();
                  var pointAdd = new BMap.Point(res.longitude, res.latitude);
                  gc.getLocation(pointAdd, function (rs) {
                    var city = rs.addressComponents.city;
                    alert(city);
                  })
                }
              });*/

              that.$message({
                message: '地理位置获取成功，经度：' + res.longitude + '，纬度：' + res.latitude,
                type: 'success'
              });
            },
            error: function (res) {
              that.$message({
                message: res,
                type: 'success'
              });
            }
          });
        })

      /*this.$nextTick(function(){

      }*/
      let flag = this.$route.query.flag;
      this.openId = localStorage.getItem("openId")
      if (flag === '1') {
        this.$message({
          message: '请使用微信客户端打开',
          type: 'warning'
        });
      }
    },
    methods: {
      login() {
        this.$router.push({path: '/userLogin'})
      },
      register() {
        this.$router.push({path: '/userRegister'})
      },
    }
  }
</script>
<style scoped>
  @import "../../assets/css/iconfont.css";
  @import "../../assets/css/login_selfcenter.css";
  @import "../../assets/css/reset.css";
</style>
